home *** CD-ROM | disk | FTP | other *** search
/ Info-Mac 1992 August / info-mac-1992.iso / Source / 3D GrafSys / GrafSys.rel / Demo Sources / xFighter < prev    next >
Text File  |  1992-04-25  |  2KB  |  86 lines

  1. program xFighterDemo1;
  2.  
  3. { 3d GrafSys Demo Program}
  4. { Vers. 1.1 }
  5. { (c) 1992 by Christian Franz }
  6.  
  7. { This program demonstates the use of the grafsys for simple animation using }
  8. { the fDrawObject command                                                                            }
  9.  
  10.     uses
  11.         GrafSys, Screen3D;
  12.  
  13.     const
  14.         theWindowID = 400;
  15.         degree = 0.01745329; (* π/180 *)
  16.  
  17.     var
  18.         theWindow: WindowPtr;
  19.         theInt: INTEGER;
  20.         thePort: Graf3DPtr;
  21.         theMaster: Graf3DPtr;
  22.         Pyramid, Cube, xFighter: GrafObjPtr;
  23.         theEvent: EventRecord;
  24.         dx, dy, dz: integer;
  25.         r: Rect;
  26.  
  27.     procedure getmouserot (var dx, dy, dz: integer);
  28.  
  29.         var
  30.             thePoint: point;
  31.  
  32.     begin
  33.         GetMouse(thePoint);
  34.         dx := 0;
  35.         dy := 0;
  36.         dz := 0;
  37.         if (thePoint.h < thePort^.center.h) and (thePoint.v < thePort^.center.v) then (* mouse in quadrant 1 -> xrot*)
  38.             begin
  39.                 dx := 5;
  40.             end;
  41.         if (thePoint.h > thePort^.center.h) and (thePoint.v < thePort^.center.v) then (* mouse in quadrant 2 -> yrot*)
  42.             begin
  43.                 dy := 5;
  44.             end;
  45.         if (thePoint.h > thePort^.center.h) and (thePoint.v > thePort^.center.v) then (* mouse in quadrant 3 -> zrot*)
  46.             begin
  47.                 dz := 5;
  48.             end;
  49.         if (thePoint.h < thePort^.center.h) and (thePoint.v > thePort^.center.v) then (* mouse in quadrant 4 -> idle*)
  50.             begin
  51.             end;
  52.         if button then
  53.             begin
  54.                 dx := -dx;
  55.                 dy := -dy;
  56.                 dz := -dz;
  57.             end;
  58.     end;
  59.  
  60.  
  61. begin
  62.     theWindow := GetNewWindow(theWindowID, nil, Pointer(-1));
  63.     SetPort(theWindow); (* draw in this window *)
  64.     ;
  65.  
  66. {PenMode(patXOR)}
  67.     MoveTo(10, 10);
  68.     DrawString('3D Grafiksystem.             Object: X-Fighter.         (C) 1991 by CF.');
  69.     InitGrafSys;
  70.     NewGrafport(theWindow^.portRect, thePort);
  71.     MoveTo(10, thePort^.bottom - 0);
  72.     DrawString(' Press Button to Exit');
  73.     xFighter := GetNewNamedObject('theFighter');
  74.     SetEye(FALSE, 0, 0, 0, 0, 0, 0, 1.57079633, false);
  75.     ObjTranslate(xFighter, 0, 0, 200);
  76.     ObjRotate(xFighter, 0 * degree, 0 * degree, 0);
  77.     ObjScale(xFighter, 1, 1, 1);
  78.     SetAutoErase(xFighter, TRUE);
  79.     fDrawObject(xFighter);
  80.     repeat
  81.         GetMouseRot(dx, dy, dz);
  82.         if (dx + dy + dz <> 0) then
  83.             fDrawObject(xfighter); (* draw Object *)
  84.         ObjRotate(xFighter, dx * degree, dy * degree, dz * degree);
  85.     until Button;
  86. end.